/**
 * add by che.zi 20150519 forzmp:679688
 */
package com.cnoc.base.datatype;

import org.springframework.util.Assert;

import java.nio.charset.Charset;

public class ZStringSerializer {
	 private final Charset charset;

	    public ZStringSerializer()
	    {
	      this(Charset.forName("UTF8"));
	    }

		public ZStringSerializer(Charset charset) {
	      Assert.notNull(charset);
	      this.charset = charset;
	    }

	    public String deserialize(byte[] bytes) {
	      return bytes == null ? null : new String(bytes, this.charset);
	    }

	    public byte[] serialize(String string) {
	      return string == null ? null : string.getBytes(this.charset);
	    }

}
